//
//  Utils.m
//  Health
//
//  Created by apple on 14-10-12.
//  Copyright (c) 2014年 scu.edu. All rights reserved.
//

#import "Utils.h"

#define USER_NAME_KEY @"USER_NAME"


@implementation Utils

+ (NSString *)buildVersion
{
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];

    return [infoDictionary objectForKey:@"CFBundleVersion"];
}

+ (NSString *)appVersion
{
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    
    return [infoDictionary objectForKey:@"CFBundleShortVersionString"];
}

+ (BOOL)userIsLogin
{
     NSString *userName = [[NSUserDefaults standardUserDefaults] objectForKey:USER_NAME_KEY];
    
    if (![userName isEqualToString:@""] && userName)
    {
        return YES;
    }
    else{
        return NO;
    }
}

+ (void)saveUserLoginToken:(SRMe *)me
{
    [[NSUserDefaults standardUserDefaults] setObject:me.userName forKey:USER_NAME_KEY];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (void)deleteUserLoginToken:(SRMe *)me
{
    [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:USER_NAME_KEY];

    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (NSString*)loginedUserName
{
    NSString *userName = [[NSUserDefaults standardUserDefaults] objectForKey:USER_NAME_KEY];
    return userName;
}




@end
